﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using NSsh.Common.Types;
using NUnit.Framework.SyntaxHelpers;
using System.IO;
using System.Collections;

namespace NSsh.Common.Tests.Types
{
    [TestFixture]
    public class PublicKeyAlgorithmHelperFixture
    {
        [Test]
        public void ShouldParseCorrectly()
        {
            Assert.That(PublicKeyAlgorithmHelper.Parse(PublicKeyAlgorithmHelper.DSA), Is.EqualTo(PublicKeyAlgorithm.DSA));
            Assert.That(PublicKeyAlgorithmHelper.Parse(PublicKeyAlgorithmHelper.RSA), Is.EqualTo(PublicKeyAlgorithm.RSA));
        }

        [Test]
        public void ShouldToStringCorrectly()
        {
            Assert.That(PublicKeyAlgorithmHelper.ToString(PublicKeyAlgorithm.DSA), Is.EqualTo(PublicKeyAlgorithmHelper.DSA));
            Assert.That(PublicKeyAlgorithmHelper.ToString(PublicKeyAlgorithm.RSA), Is.EqualTo(PublicKeyAlgorithmHelper.RSA));
        }

        [Test]
        public void ShouldFailForInvalidAlgorithm()
        {
            Assert.That(new MethodInvoker(delegate
            {
                PublicKeyAlgorithmHelper.ToString((PublicKeyAlgorithm) ( -1));

            }), Throws.Exception<ArgumentException>());

            Assert.That(new MethodInvoker(delegate
            {
                PublicKeyAlgorithmHelper.Parse("bogus");

            }), Throws.Exception<ArgumentException>());
        }
    }
}
